{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 1,
   "id": "b72eeb38-d034-4ccc-a76a-97e1fc2e00fd",
   "metadata": {},
   "outputs": [],
   "source": [
    "# define functions\n",
    "def get_IAT_useful_cols(data):\n",
    "    useful_iat_cols = ['response.interval_time',\n",
    "                       'block_order_type',\n",
    "                       'response.corr',\n",
    "                       'response.rt',\n",
    "                       'BlockType',\n",
    "                       'TrialType',\n",
    "                       '请填写您的姓名：',\n",
    "                       '请填写您的学号：']\n",
    "    data = data[useful_iat_cols]\n",
    "    return data"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "id": "d8bfac63-472e-41f9-89b2-edebd5de46a9",
   "metadata": {},
   "outputs": [],
   "source": [
    "import pandas as pd"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "id": "6288953c-dfd9-49e3-8e84-e1197522005b",
   "metadata": {},
   "outputs": [],
   "source": [
    "# 读取文件\n",
    "data = pd.read_csv('贾小艺__IAT_2021_Nov_28_1522.csv',engine='python',sep=',')\n",
    "# 选中需要进行分析的列\n",
    "data = get_IAT_useful_cols(data)\n",
    "# 删掉空行\n",
    "data = data.dropna(how='all')\n",
    "# output\n",
    "new_name = '贾小艺' + '_' + 'cleaned' + '.xlsx' \n",
    "data.to_excel(new_name)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "e0a703ba-b441-4a79-bcca-1a3822b944e5",
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.8.8"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
